package top.chmin.project.cloud.common.entity.column.relation.auto;

// field import auto
// #bind.field.id#

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import top.chmin.project.cloud.common.entity.*;

/**
 * chmin
 * 2023-12-27 15:15:42
 * cloud-builder
 */
@Getter
@Setter
@Accessors(chain = true)
public class EntityColumnRelation extends Model {

    // field auto
// #bind.field.sourceFieldCode#
    // 依赖字段
    private String sourceFieldCode;
// $bind.field.sourceFieldCode$

    // #bind.field.targetFieldCode#
    // 被依赖属性
    private String targetFieldCode;
// $bind.field.targetFieldCode$

    // #bind.field.sourceTableCode#
    // 依赖表名
    private String sourceTableCode;
// $bind.field.sourceTableCode$

    // #bind.field.targetTableCode#
    // 被依赖表名
    private String targetTableCode;
// $bind.field.targetTableCode$


    @Override
    public EntityColumnRelationEPC getPreCondition() {
        return new EntityColumnRelationEPC();
    }

    public class EntityColumnRelationEPC extends PreCondition {
        private EntityColumnRelationEPC() {
        }

        private EntityColumnRelationEPC(EntityColumnRelationEPC parent) {
            super(parent);
        }

        public EntityColumnRelationEPC forUpdate() {
            addUpdateSql("update_time = ?", updateTime);
            addUpdateSql("update_by = ?", updateBy);
// field update auto
// #bind.field.sourceFieldCode#
            addUpdateSql("source_field_code = ?", sourceFieldCode);
// $bind.field.sourceFieldCode$

// #bind.field.targetFieldCode#
            addUpdateSql("target_field_code = ?", targetFieldCode);
// $bind.field.targetFieldCode$

// #bind.field.sourceTableCode#
            addUpdateSql("source_table_code = ?", sourceTableCode);
// $bind.field.sourceTableCode$

// #bind.field.targetTableCode#
            addUpdateSql("target_table_code = ?", targetTableCode);
// $bind.field.targetTableCode$

            type = "UPDATE";
            return this;
        }

        public EntityColumnRelationEPC forDelete() {
            type = "DELETE";
            return this;
        }

        public EntityColumnRelationEPC forCount() {
            type = "COUNT";
            return this;
        }

        public EntityColumnRelationEPC sub() {
            return new EntityColumnRelationEPC(this);
        }

        public EntityColumnRelationEPC complete(boolean and) {
            finish(and);
            return parent == null ? this : (EntityColumnRelationEPC) parent;
        }

        public EntityColumnRelationFPC toFlex() {
            EntityColumnRelationFPC flex = new EntityColumnRelationFPC();
            flex.setUpdateSqlList(updateSqlList);
            flex.setUpdateValueList(updateValueList);
            flex.setSqlList(sqlList);
            flex.setValueList(valueList);
            flex.setType(type);
            return flex;
        }

        public Condition toCondition() {
            return toCondition(EntityColumnRelation.class, "bs_entity_column_relation");
        }

        // field epc auto
// #bind.field.id#
        public Id id() {
            return new Id();
        }

        // #bind.field.createBy#
        public CreateBy createBy() {
            return new CreateBy();
        }
// $bind.field.id$

        // #bind.field.updateBy#
        public UpdateBy updateBy() {
            return new UpdateBy();
        }

        // #bind.field.createTime#
        public CreateTime createTime() {
            return new CreateTime();
        }
// $bind.field.createBy$

        // #bind.field.updateTime#
        public UpdateTime updateTime() {
            return new UpdateTime();
        }

        // #bind.field.sourceFieldCode#
        public SourceFieldCode sourceFieldCode() {
            return new SourceFieldCode();
        }
// $bind.field.updateBy$

        // #bind.field.targetFieldCode#
        public TargetFieldCode targetFieldCode() {
            return new TargetFieldCode();
        }

        // #bind.field.sourceTableCode#
        public SourceTableCode sourceTableCode() {
            return new SourceTableCode();
        }
// $bind.field.createTime$

        // #bind.field.targetTableCode#
        public TargetTableCode targetTableCode() {
            return new TargetTableCode();
        }

        public class Id extends LongEPCField<EntityColumnRelationEPC> {
            private Id() {
                super(EntityColumnRelationEPC.this, "id", id);
            }
        }
// $bind.field.updateTime$

        public class CreateBy extends StringEPCField<EntityColumnRelationEPC> {
            private CreateBy() {
                super(EntityColumnRelationEPC.this, "create_by", createBy);
            }
        }

        public class UpdateBy extends StringEPCField<EntityColumnRelationEPC> {
            private UpdateBy() {
                super(EntityColumnRelationEPC.this, "update_by", updateBy);
            }
        }
// $bind.field.sourceFieldCode$

        public class CreateTime extends LocalDateTimeEPCField<EntityColumnRelationEPC> {
            private CreateTime() {
                super(EntityColumnRelationEPC.this, "create_time", createTime);
            }
        }

        public class UpdateTime extends LocalDateTimeEPCField<EntityColumnRelationEPC> {
            private UpdateTime() {
                super(EntityColumnRelationEPC.this, "update_time", updateTime);
            }
        }
// $bind.field.targetFieldCode$

        public class SourceFieldCode extends StringEPCField<EntityColumnRelationEPC> {
            private SourceFieldCode() {
                super(EntityColumnRelationEPC.this, "source_field_code", sourceFieldCode);
            }
        }

        public class TargetFieldCode extends StringEPCField<EntityColumnRelationEPC> {
            private TargetFieldCode() {
                super(EntityColumnRelationEPC.this, "target_field_code", targetFieldCode);
            }
        }
// $bind.field.sourceTableCode$

        public class SourceTableCode extends StringEPCField<EntityColumnRelationEPC> {
            private SourceTableCode() {
                super(EntityColumnRelationEPC.this, "source_table_code", sourceTableCode);
            }
        }

        public class TargetTableCode extends StringEPCField<EntityColumnRelationEPC> {
            private TargetTableCode() {
                super(EntityColumnRelationEPC.this, "target_table_code", targetTableCode);
            }
        }
// $bind.field.targetTableCode$

    }
}
